//
//  PaymentTableViewCell.m
//  shanHaiHuiApp
//
//  Created by 小和尚 on 2018/3/10.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "PaymentTableViewCell.h"
@interface PaymentGoodTableViewCell()

Strong UIImageView * picImageView;
Strong UILabel * contentLabel;
Strong UILabel * priceLabel;

@end

@implementation PaymentGoodTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    self = [super initWithCellIdentifier:cellID];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _picImageView = [UIImageView new];
        _picImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = DEF_FontSize_14;
        _contentLabel.textColor = getColor(@"666666");
        
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.font = DEF_FontSize_14;
        _priceLabel.textColor = getColor(@"323232");
        
        [self sd_addSubviews:@[self.picImageView,self.contentLabel,self.priceLabel]];
        
        [self layOutFrame];
        
    }
    return self;
}

- (void)layOutFrame{
    ws(self);
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(15));
        make.top.mas_equalTo(UNIT_WIDTH(15));
        make.height.mas_equalTo(UNIT_HEIGHT(18));
        make.width.mas_equalTo(UNIT_WIDTH(22));
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(12));
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.picImageView.image = [UIImage imageNamed:model[@"image"]];
    self.contentLabel.text = model[@"content"];
    self.priceLabel.text = model[@"price"];
}

@end


@interface PaymentCardTableViewCell()

//批号
Strong UILabel * cardLabel;
Strong UILabel * cardDetailLabel;
//库存
Strong UILabel * kucunLabel;
Strong UILabel * kucunDetailLabel;
//到期日
Strong UILabel * dateLabel;
Strong UILabel * dateDetailLabel;
//数量
Strong UILabel * countLabel;
Strong UILabel * countDetailLabel;
//修改批次批号
//Strong UIButton * changeCardBtn;

Strong UIView * lineView;

@end


@implementation PaymentCardTableViewCell

#pragma Action---

- (void)changeCardBtnClick{
    
    if (_getchangeCardBtnClick) {
        _getchangeCardBtnClick();
    }
}

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        
         self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _cardLabel = [[UILabel alloc] init];
        _cardLabel.text = @"批号-批次";
        _cardLabel.textColor = getColor(textColor);
        _cardLabel.font = DEF_FontSize_11;
        
        _cardDetailLabel = [[UILabel alloc] init];
        _cardDetailLabel.text = @"456789999";
        _cardDetailLabel.textColor = getColor(textColor);
        _cardDetailLabel.font = DEF_FontSize_11;
        
        
        _kucunLabel = [[UILabel alloc] init];
        _kucunLabel.text = @"库存";
        _kucunLabel.textColor = getColor(textColor);
        _kucunLabel.font = DEF_FontSize_11;
        
        _kucunDetailLabel = [[UILabel alloc] init];
        _kucunDetailLabel.text = @"99";
        _kucunDetailLabel.textColor = getColor(textColor);
        _kucunDetailLabel.font = DEF_FontSize_11;
        
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.text = @"到期日";
        _dateLabel.textColor = getColor(textColor);
        _dateLabel.font = DEF_FontSize_11;
        
        _dateDetailLabel = [[UILabel alloc] init];
        _dateDetailLabel.text = @"20190101";
        _dateDetailLabel.textColor = getColor(textColor);
        _dateDetailLabel.font = DEF_FontSize_11;
        
        _countLabel = [[UILabel alloc] init];
        _countLabel.text = @"数量";
        _countLabel.textColor = getColor(textColor);
        _countLabel.font = DEF_FontSize_11;
        
        _countDetailLabel = [[UILabel alloc] init];
        _countDetailLabel.text = @"10";
        _countDetailLabel.textColor = getColor(textColor);
        _countDetailLabel.font = DEF_FontSize_11;
        
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(dividerColor);
        

        [self sd_addSubviews:@[self.cardLabel,self.cardDetailLabel,self.kucunLabel,self.kucunDetailLabel,self.dateLabel,self.dateDetailLabel,self.countLabel,self.countDetailLabel,self.lineView]];
        
        [self layOutFrame];
        
        
    }
    
    return self;
    
}

- (void)layOutFrame{
    ws(self)
    [self.cardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(UNIT_HEIGHT(15));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.cardDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.cardLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.kucunLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(weakself.cardLabel.mas_bottom).offset(UNIT_HEIGHT(9));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.kucunDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.kucunLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(weakself.kucunLabel.mas_bottom).offset(UNIT_HEIGHT(9));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.dateDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.dateLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(weakself.dateLabel.mas_bottom).offset(UNIT_HEIGHT(9));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    [self.countDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.countLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(UNIT_HEIGHT(1));
    }];
    
}

- (void)setModel:(SpphModel *)model{
    
    _model = model;
    
    self.cardDetailLabel.text = [NSString stringWithFormat:@"%@-%@",model.fPh,model.fPc];
    self.kucunDetailLabel.text = [NSString stringWithFormat:@"%@",model.fSl];
    self.dateDetailLabel.text = [NSString stringWithFormat:@"%@",model.fDqdate];
    self.countDetailLabel.text = [NSString stringWithFormat:@"%@",model.xssl];
    
}


@end


//头部视图
@interface PaymentCardHeaderTableViewCell()

@end

@implementation PaymentCardHeaderTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(44))];
        whiteView.backgroundColor = getColor(whiteColor);
        
        UILabel * goodNameLabel = [[UILabel alloc] init];
        goodNameLabel.text = @"商品名称";
        goodNameLabel.textColor = getColor(textColor);
        goodNameLabel.font = DEF_FontSize_11;
        
        UILabel * conntLabel = [[UILabel alloc] init];
        conntLabel.textColor = getColor(textColor);
        conntLabel.font = DEF_FontSize_11;
        conntLabel.text = @"数量";
        
        UILabel * moneyLabel = [[UILabel alloc] init];
        moneyLabel.textColor = getColor(textColor);
        moneyLabel.font = DEF_FontSize_11;
        moneyLabel.text = @"金额";
        
        [self.contentView addSubview:whiteView];
        
        [whiteView sd_addSubviews:@[goodNameLabel,conntLabel,moneyLabel]];
        
        [goodNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(UNIT_WIDTH(15));
            make.top.mas_equalTo(UNIT_HEIGHT(0));
            make.bottom.mas_equalTo(0);
        }];
        
        [conntLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(UNIT_WIDTH(250));
            make.top.mas_equalTo(UNIT_HEIGHT(0));
            make.bottom.mas_equalTo(0);
        }];
        
        [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(UNIT_WIDTH(-15));
            make.top.mas_equalTo(UNIT_HEIGHT(0));
            make.bottom.mas_equalTo(0);
        }];
        
        
    }
    return self;
}

@end


//头部视图
@interface PaymentGoodShowTableViewCell()


Strong UIView * headerView;


Strong UIView * lineView;

Strong UIImageView * picImageView;

Strong UILabel * nameLabel;
Strong UILabel * countLabel1;
Strong UILabel * moneyLabel;
Strong CLCustomButton * spreadBtn;

Strong UIView * TopLineView;


@end

@implementation PaymentGoodShowTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(90))];
        
        _headerView.backgroundColor = getColor(whiteColor);
        
        _TopLineView = [[UIView alloc] init];
        _TopLineView.backgroundColor = getColor(dividerColor);
        
        _picImageView = [UIImageView new];
        _picImageView.image = [UIImage imageNamed:@"shanhaihuilogo"];
        _picImageView.layer.masksToBounds = YES;
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"三只松鼠,三只松鼠,三只松鼠";
        _nameLabel.font = DEF_FontSize_13;
        _nameLabel.textColor = getColor(@"323232");
        _nameLabel.numberOfLines = 0;
        
        _countLabel1 = [[UILabel alloc] init];
        _countLabel1.text = @"X10";
        _countLabel1.textColor = getColor(@"323232");
        _countLabel1.font = DEF_FontSize_13;
        
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.textColor = getColor(@"323232");
        _moneyLabel.text=@"49";
        _moneyLabel.font = DEF_FontSize_13;
        
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(dividerColor);
        
        [self addSubview:_headerView];
        
        [_headerView sd_addSubviews:@[self.picImageView,self.nameLabel,self.countLabel1,self.moneyLabel,self.lineView,self.TopLineView]];
        
        //_spreadBtn = [[CLCustomButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH  - 55,  CGRectGetMaxY(_moneyLabel.frame) + 50, 40,40) type:CLCustomButtonLeftImageType imageSize:CGSizeMake(16,8) midmargin:5];
        
        _spreadBtn = [[CLCustomButton alloc] initWithFrame:CGRectMake(0,0,0,0) type:CLCustomButtonLeftImageType imageSize:CGSizeMake(16,8) midmargin:5];
        _spreadBtn.isShowSelectBackgroudColor = NO;
        _spreadBtn.imageView.image = [UIImage imageNamed:@"zhankai"];
        _spreadBtn.titleLabel.text = @"展开";
        _spreadBtn.titleLabel.textColor = getColor(@"CCCCCC");
        _spreadBtn.titleLabel.font = DEF_FontSize_11;
        _spreadBtn.backgroundColor = [UIColor whiteColor];
    
        [self.spreadBtn touchAction:^(CLCustomButton * _Nonnull button) {
            
            self.model.isOpening = !self.model.isOpening;
            
            if (self.model.isOpening) {
                
                self.spreadBtn.hidden = YES;
                
            }else{
                
                self.spreadBtn.hidden = NO;
                
            }
            
            
            if (_getShowClick) {
                _getShowClick(self,self.model.isOpening);
            }
            
        }];
        
        
        [_headerView addSubview:self.spreadBtn];
        
        
        
        ws(self)
        
        [self.TopLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.left.mas_equalTo(0);
            make.right.mas_equalTo(0);
            make.height.mas_equalTo(UNIT_HEIGHT(1));
        }];
        
        
        [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(UNIT_HEIGHT(15));
            make.left.mas_equalTo(UNIT_WIDTH(15));
            make.width.mas_equalTo(UNIT_WIDTH(40));
            make.height.mas_equalTo(UNIT_HEIGHT(40));
        }];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
            make.top.mas_equalTo(UNIT_WIDTH(15));
            make.width.mas_equalTo(UNIT_WIDTH(151));
        }];
        
        [self.countLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakself.nameLabel.mas_right).offset(30);
            make.top.mas_equalTo(UNIT_WIDTH(15));
            make.width.mas_equalTo(UNIT_WIDTH(35));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(UNIT_WIDTH(-15));
            make.top.mas_equalTo(UNIT_WIDTH(15));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.mas_equalTo(0);
            make.right.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
            make.bottom.mas_equalTo(0);
        }];
        
        [self.spreadBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
            make.width.mas_equalTo(UNIT_WIDTH(100));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            
            
        }];
       
        
        
    }
    
    return self;
    
}

- (void)setModel:(PayMentGoodModel *)model{
    
    _model = model;
    
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.imagepfilename]];
    self.nameLabel.text = model.spmc;
    
    self.countLabel1.text = [NSString stringWithFormat:@"×%@",model.xssl];
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",model.xsje];
    
    if (model.isOpening) {
        
        self.spreadBtn.hidden = YES;
        
    }else{
        
        self.spreadBtn.hidden = NO;
        
    }
    
}



@end
